Allow empty authority in absolute URIs#698
Allow empty authority in absolute URIs#698andrewbaxter wants to merge 1 commit intohyperium:masterfrom
Conversation
|
I'm not immediately against this change, but I am a bit skeptical. Notably, this crate is purposefully meant for the HTTP usecase, not a general URL parser. ( |
|
Also, recently opened: #696. |
|
FWIW I opened this because I thought @carllerche had given the okay for it in #323 , but you're right, this is Despite varied requirements, the rust ecosystem still hasn't seen a second Uri crate and this is used pretty widely - I'm not sure the ecosystem could support another implementation of a Uri crate. Is there a way some of the core functionality could be shared with another crate with a more permissive frontend in such a way that the types would be trivially convertible? On the other hand, I don't think any software relies on this check for correct operation... I think this error is at most used to detect user mistakes early. And in that case, I think other code that consumes |
PawelBis
left a comment
There was a problem hiding this comment.
Great work. Can we get this merged? It is really necessary for webview.
This is copy of: hyperium#698
|
Could this be merged? |
|
I think there'd be less misuse of this type if it was called I agree with the assessment that this crate is designed for specifically HTTP URI use cases, and for generic URL situations (client-side, webview, etc) something more like the |
|
Seems like we're stuck here between two crates:
|
|
Since the authority (and scheme, username, password...) is usually removed before being sent to a server inside HTTP, it can be necessary to create a URI appropriate for use there. Such as when the connection is to a device over link-layer v6, discovered via mDNS. One can not pass a name for the authority, because the socket needs to be properly crafted. |
Fixes #323
This removes the restriction preventing empty
authorityin URIs. The canonical example of this isfile:///which has a zero-length authority. While these may not be relevant for a web server, there are many domains that need these sorts of alternative URIs (for example Webview-based software which reads local resources).https://datatracker.ietf.org/doc/html/rfc3986 pretty clearly describes the authority as optional in all situations AFAICT, but it mentions that schema-specific restrictions may be in place.
This is the case for HTTP addresses, described in https://www.rfc-editor.org/rfc/rfc9110.html#name-identifiers-in-http
It's possible that some users of this library in a strictly-http context may be relying on this checking the validity of the HTTP identifier for them. I'm not sure how to handle this, maybe with a version bump? The legacy behavior could be considered a bug though.
Eventually a separate HttpUri type or something that performs the additional checks when constructed might be useful.